import { reactive, inject, provide } from 'vue';
import { ConsoleLogger } from '@/utils/debug-log';
import { menuData } from '@/domain/newHope/hooks/menuInfo';
import { RouteRecordRaw } from 'vue-router';

const console = new ConsoleLogger('菜单数据');
const useStateSymbol = Symbol('useState store');

export interface IMenuState {
  menuData: Array<any>;
}

export interface IMenuMenuStoreFn {
  (): IUseMenuStore;
}

export interface IUseMenuStore {
  state: IMenuState;
}

export const useMenuProvide: () => IUseMenuStore = () => {
  const state = reactive<IMenuState>({
    menuData: menuData
  });

  const store: IUseMenuStore = {
    state
  };

  provide(useStateSymbol, { ...store });

  return store;
};

/**
 *  * useMenuStore 用户hooks.
 * @function
 * @returns store extend IUseMenuStore
 */
export const useMenuStore: IMenuMenuStoreFn = () => {
  const store: IUseMenuStore = inject(useStateSymbol) as IUseMenuStore;
  return store;
};
